export function getTree() {
    const data = [
        { channel: '抖音', shopName: 'VFU抖一抖店-抖音VFU', brand: 'VFU' },
        { channel: '抖音', shopName: 'VFU-抖音小店VFU', brand: 'VFU' },
        { channel: '头条放心购', shopName: 'VFU-头条放心购VFU', brand: 'VFU' },
        { channel: '拼多多', shopName: 'VFU-拼多多VFU', brand: 'VFU' },
        { channel: '微信', shopName: 'VFU-微店VFU', brand: 'VFU' },
        { channel: '微信', shopName: 'VFU-微信商城VFU', brand: 'VFU' },
        { channel: '小红书', shopName: 'VFU-小红书VFU', brand: 'VFU' },
        { channel: '严选', shopName: 'VFU-严寻合作VFU', brand: 'VFU' },
        { channel: '天猫', shopName: 'VFU运动旗舰店VFU', brand: 'VFU' },
        { channel: '京东', shopName: 'VFU运动旗舰店-京东', brand: 'VFU' }
    ];

    // 创建一个空的结果数组
    const result = [];

    // 遍历原始数据
    data.forEach(item => {
        const brandIndex = result.findIndex(brandItem => brandItem.value === item.brand);

        // 如果品牌不存在于结果数组中，则创建一个新的品牌对象并添加到结果数组中
        if (brandIndex === -1) {
            const brandObj = {
                label: item.brand,
                value: item.brand,
                children: []
            };
            result.push(brandObj);
        }

        // 获取品牌对象
        const brandObj = result[brandIndex];

        const channelIndex = brandObj.children.findIndex(channelItem => channelItem.value == item.channel);

        // 如果渠道不存在于品牌对象的子数组中，则创建一个新的渠道对象并添加到子数组中
        if (channelIndex === -1) {
            const channelObj = {
                label: item.channel,
                value: item.channel,
                children: []
            };
            brandObj.children.push(channelObj);
        }

        // 获取渠道对象
        const channelObj = brandObj.children[channelIndex];

        // 创建并添加店铺对象到渠道对象的子数组中
        const shopObj = {
            label: item.shopName,
            value: item.shopName
        };
        channelObj.children.push(shopObj);
    });

    console.log(result);
    return result
}
